using System;
using System.Collections.Generic;
using System.Text;

namespace HexterConsulting
{
    class BinaryToCSVConverter
    {
        const string arguments = "/c relog \"{0}\" -y -f CSV -o \"{1}\"";
        private string sourceFilename;
        private string destinationFilename=string.Empty;

        public BinaryToCSVConverter(string SourceFilename)
        {
            this.sourceFilename = SourceFilename;
            this.destinationFilename = System.IO.Path.GetDirectoryName(sourceFilename) + "\\" + System.IO.Path.GetFileNameWithoutExtension(sourceFilename) + ".csv";
        }

        public void Convert()
        {
            System.Diagnostics.Process process = CreateProcess();
            process.Start();
            process.WaitForExit();
        }

        private System.Diagnostics.Process CreateProcess()
        {
            System.Diagnostics.Process process = new System.Diagnostics.Process();
            System.Diagnostics.ProcessStartInfo processStartInfo = new System.Diagnostics.ProcessStartInfo();
            processStartInfo.FileName = "cmd";
            processStartInfo.Arguments = string.Format(arguments, sourceFilename, destinationFilename);
            processStartInfo.UseShellExecute = true;
            processStartInfo.CreateNoWindow = true;
            processStartInfo.RedirectStandardOutput = false;
            processStartInfo.RedirectStandardError = false;
            process.StartInfo = processStartInfo;
            return process;
        }
        public string DestinationFilename
        {
            get { return this.destinationFilename; }

        }
    }
}
